package com.qikux.vo;

import java.util.List;

public class PageVo<T> {
    /**
     * 页码
     */
    private Long page ;
    /**
     * 每页显示条数
     */
    private Long rows ;
    /**
     * 当前页需要的数据
     */
    private List<T> list ;

    /**
     * 查询的 条数
     */
    private long total ;

    public PageVo() {}

    public PageVo(Long page, Long rows) {
        this.page = page;
        this.rows = rows;
    }

    public Long getPage() {
        return page;
    }

    public void setPage(Long page) {
        this.page = page;
    }

    public Long getRows() {
        return rows;
    }

    public void setRows(Long rows) {
        this.rows = rows;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    /**
     * 返回总页数
     * @return
     */
    public long getPages() {
        return (this.total - 1) / this.rows + 1 ;
    }

    /**
     * mysql 分页需要的偏移量
     * @return
     */
    public long getOffset() {
        return (this.page - 1) * this.rows ;
    }

}
